﻿Option Strict Off

Imports DBUtilitiesLibrary
Imports DARSClassLibrary
'Jihad Abouhatab
'
'

Public Class ApptStatusModification
    Inherits System.Web.UI.Page

    Dim CurrentAdvisorID As String

    ' Dim objDB As New DARSDBConnection
    'for this to work, you also need a session variable after a successful login of an Advisor : Session("AdvisorID")
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Check if user is logged in
        

        If Session("CurrentUser") Is Nothing Then
            Response.Redirect("NotLoggedIn.aspx")
            Exit Sub
        End If

        If Not IsPostBack Then
            'GridView1.Visible = True
            GridView2.Visible = False
            Label4.Visible = False
            Label5.Visible = False
            DropDownList3.Visible = False
            TextBox1.Visible = False
            Button2.Visible = False
            TextBox2.Visible = False
            TextBox3.Visible = False
            TextBox4.Visible = False
            ' Session("AdvisorID") = DropDownList1.SelectedValue


            GridView1.Visible = True
            ' DropDownList1.Visible = False

            Dim objAdviser As Advisor = CType(Session("CurrentUser"), Advisor)
            Label2.Text = objAdviser.FirstName & objAdviser.LastName
            Label1.Text = objAdviser.AdvisorID
            Session.Add("CurrentAdvisorID", objAdviser.AdvisorID)
            CurrentAdvisorID = Session("CurrentAdvisorID")
        End If
    End Sub

    
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        GridView1.Visible = False
        GridView2.Visible = True
        Button1.Visible = False
        Label4.Visible = True
        Label5.Visible = True
        DropDownList3.Visible = True
        TextBox1.Visible = True
        Button2.Visible = True

        TextBox2.Visible = True
        TextBox3.Visible = True
        TextBox4.Visible = True

        Label6.Visible = False
        Label7.Visible = False
        Label8.Visible = False
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
        Dim dt1 As DateTime = TextBox1.Text
        Dim dt2 As DateTime = DropDownList3.SelectedValue
        CurrentAdvisorID = Session("CurrentAdvisorID")

        Dim ws As New DO_NOT_MOVE_ME_FROM_THIS_PROJECT.DARSWebservice
        ws.changeAppointmentDateTime(CurrentAdvisorID, dt2, dt1)
        lblSubmit.Text = "Appointment DateTime updated. Your new appointment DateTime is " & dt1 & "."

        TextBox2.Text = dt1
        TextBox3.Text = dt2
        TextBox4.Text = CurrentAdvisorID
        
        Label3.Visible = False

        TextBox2.Enabled = False
        TextBox3.Enabled = False
        TextBox4.Enabled = False
    End Sub

    Protected Sub logout(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.ServerClick
        Session.Abandon()
        Response.Redirect("NotLoggedIn.aspx")
    End Sub

    Protected Sub home(ByVal sender As Object, ByVal e As EventArgs) Handles btnhome.ServerClick
        Response.Redirect("AdvisorLandingPage.aspx")
    End Sub
   
End Class